package morning.cat.bpp;

import morning.cat.service.UserServiceProxy;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.GenericBeanDefinition;

/**
 * @describe: 类描述信息
 * @author: morningcat.zhang
 * @date: 2020/1/6 10:05 PM
 */
//@Component
public class UserBeanFactoryPostProcessor implements BeanFactoryPostProcessor {

	@Override
	public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
		BeanDefinition beanDefinition = beanFactory.getBeanDefinition("userService");
		if (beanDefinition instanceof GenericBeanDefinition) {
			GenericBeanDefinition genericBeanDefinition = (GenericBeanDefinition) beanDefinition;
			genericBeanDefinition.setBeanClass(UserServiceProxy.class);
		}

	}
}
